<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:replace="common/base::pagetitle"></title>
    <link th:replace="common/base::static"/>
</head>
<body>
<div class="layui-form" style="padding: 20px 30px 0 0;">
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">关联用户id</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="accountId" th:value="${editInfo.accountId}" lay-verify="required" placeholder="请输入关联用户id" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">任务名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" th:value="${editInfo.name}" lay-verify="required" placeholder="请输入任务名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">搜索源（搜索关键字）</label>
        <div class="layui-input-inline">
            <input type="text" name="searchKeyword" th:value="${editInfo.searchKeyword}" lay-verify="required" placeholder="请输入搜索源（搜索关键字）" autocomplete="off" class="layui-input">
        </div>
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">任务状态</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="radio" name="status" value="0" title="运行中" autocomplete="off" class="layui-input" th:checked="${editInfo.status==0}">-->
<!--            <input type="radio" name="status" value="1" title="已完成" autocomplete="off" class="layui-input" th:checked="${editInfo.status==1}">-->
<!--            <input type="radio" name="status" value="2" title="已结束" autocomplete="off" class="layui-input" th:checked="${editInfo.status==2}">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">搜索排序</label>
        <div class="layui-input-block">
            <input type="radio" name="siftSort" value="0" title="默认" autocomplete="off" class="layui-input" th:checked="${editInfo.siftSort==0}">
            <input type="radio" name="siftSort" value="1" title="最新发布" autocomplete="off" class="layui-input" th:checked="${editInfo.siftSort==1}">
            <input type="radio" name="siftSort" value="2" title="最多点赞" autocomplete="off" class="layui-input" th:checked="${editInfo.siftSort==2}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">视频发布时间</label>
        <div class="layui-input-block">
            <input type="radio" name="siftCondition" value="0" title="默认" autocomplete="off" class="layui-input" th:checked="${editInfo.siftCondition==0}">
            <input type="radio" name="siftCondition" value="1" title="一天内" autocomplete="off" class="layui-input" th:checked="${editInfo.siftCondition==1}">
            <input type="radio" name="siftCondition" value="2" title="一周内" autocomplete="off" class="layui-input" th:checked="${editInfo.siftCondition==2}">
            <input type="radio" name="siftCondition" value="3" title="半年内" autocomplete="off" class="layui-input" th:checked="${editInfo.siftCondition==3}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">意向客户数量</label>
        <div class="layui-input-inline">
            <input type="text" name="custNum" th:value="${editInfo.custNum}" lay-verify="required" placeholder="请输入意向客户数量" autocomplete="off" class="layui-input">
        </div>
    </div>
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">线索视频数量</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="videoNum" th:value="${editInfo.videoNum}" placeholder="请输入线索视频数量" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">修改时间</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="updateTime" id="updateTime" th:value="${#strings.replace(editInfo.updateTime,'T',' ')}" placeholder="请输入修改时间" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">媒体类别， 1: 抖音 2: 快手 3: 小红书</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="mediumType" th:value="${editInfo.mediumType}" lay-verify="required" placeholder="请输入媒体类别， 1: 抖音 2: 快手 3: 小红书" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">使用客户数量</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="useCustNum" th:value="${editInfo.useCustNum}" lay-verify="required" placeholder="请输入使用客户数量" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">筛选关键词</label>
        <div class="layui-input-inline">
            <textarea type="text" name="siftKeywords" id="siftKeywords"  th:value="${editInfo.siftKeywords}" lay-verify="required" placeholder="请输入筛选关键词" style="height: 100px;width: 500px;" autocomplete="off" class="layui-input" rows="3"></textarea>
            <input type="hidden" id="sift" th:value="${editInfo.siftKeywords}"/>
            <div id="commentKeywords" style="width: 600px">
                <!--动态添加 span标签-->
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">屏蔽关键词</label>
        <div class="layui-input-inline">
            <textarea type="text" name="shieldKeywords" id="shieldKeywords" th:value="${editInfo.shieldKeywords}" placeholder="请输入屏蔽关键词" style="height: 100px;width: 500px;" autocomplete="off" class="layui-input" rows="3"></textarea>
            <input type="hidden" id="shield" th:value="${editInfo.shieldKeywords}"/>
            <div id="prohibitKeywords" style="width: 600px">
                <!--动态添加 span标签-->
            </div>
        </div>
    </div>

    <div class="layui-form-item">
         <label class="layui-form-label">定时截至时间</label>
         <div class="layui-input-inline">
             <input type="text" name="timedTime" id="timedTime" th:value="${#strings.replace(editInfo.timedTime,'T',' ')}" lay-verify="required" placeholder="请输入定时截至时间" autocomplete="off" class="layui-input">
         </div>
    </div>

    <div class="layui-form-item">
         <label class="layui-form-label">创建时间</label>
         <div class="layui-input-inline">
             <input type="text" name="createTime" id="createTime" th:value="${#strings.replace(editInfo.createTime,'T',' ')}" lay-verify="required" placeholder="请输入创建时间" autocomplete="off" class="layui-input">
         </div>
    </div>
        <!--此为隐藏域表单 1为同行博主分析-->
    <input type="hidden" name="category" value="1">
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">类别：0关键字分析，1同行博主分析，2精准视频分析</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="category" th:value="${editInfo.category}" placeholder="请输入类别：0关键字分析，1同行博主分析，2精准视频分析" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">创建人</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="createUser" th:value="${editInfo.createUser}" placeholder="请输入创建人" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">修改人</label>-->
<!--        <div class="layui-input-inline">-->
<!--            <input type="text" name="updateUser" th:value="${editInfo.updateUser}" placeholder="请输入修改人" autocomplete="off" class="layui-input">-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit="" lay-filter="kFormSubmit" id="kFormSubmit">
        <input type="text" name="id" th:value="${editInfo.id}" autocomplete="off" class="layui-input">
    </div>
</div>

<script th:replace="common/base::context"></script>
<script th:replace="common/base::mainjs"></script>
<script>
    layui.use(['form', 'laydate'], function () {
        var $ = layui.$, form = layui.form, laydate = layui.laydate;

        laydate.render({
            elem: '#timedTime' // 指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#createTime' // 指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#updateTime' // 指定元素
            ,type: 'datetime'
        });

        //监听提交
        form.on('submit(kFormSubmit)', function(data){
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            var url = field.id ? 'dy/taskblo/edit' : 'dy/taskblo/add';
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.ajax({
                type: req.type.post,
                url: BASE_WEB + url,
                data: field,
                async: false,
                success: function (r) {
                    if (r.code === req.status.ok) {
                        //重载表格
                        parent.layui.table.reload('kContentTable');
                        parent.layer.close(index); //再执行关闭
                    } else {
                        kvfKit.errorMsg(r.msg);
                    }
                }
            });
        });
    });

    //筛选关键字
    $.post(BASE_WEB + 'hxy/keyword/getKeywords',{
        'keywordType': 1
    },function(res){
        if(res.code==200){
                //文本输入框累加值
                var siftValues = "";
                let map = new Map();
                var mainPanel = document.getElementById("commentKeywords");
                for(var i=0; i<res.data.length; i++){
                    var childDiv = document.createElement("span");
                    childDiv.style.background = "#3ca793";
                    childDiv.style.padding = "5px";
                    childDiv.style.marginBottom = "3px";
                    childDiv.style.marginTop = "2px";
                    childDiv.style.marginRight = "5px";
                    childDiv.style.color = "#fff";
                    childDiv.style.display = "inline-block";
                    childDiv.style.cursor = "pointer";
                    childDiv.id = 'c'+i;
                    childDiv.innerHTML = '<span>'+res.data[i]+'</span>';
                    mainPanel.appendChild(childDiv);
                    childDiv.onclick = function (  ) {

                        if(map.get(this.id) != null){
                            layer.msg("请勿重复添加!");
                            return;
                        }else {
                            //单个span标签的值
                            var spanValue = document.getElementById(this.id).innerText+",";
                            siftValues=siftValues+spanValue;
                            document.getElementById('siftKeywords').value=siftValues.substring(0, siftValues.length - 1);
                            map.set(this.id,spanValue);
                        }

                    }
                }
        }else {
            layer.msg(res.msg);
        }
    });



    //屏蔽关键字
    $.post(BASE_WEB + 'hxy/keyword/getKeywords',{
        'keywordType': 2
    },function(res){
        if(res.code==200){
            //文本输入框累加值
            var prohibitValues = "";
            let map = new Map();
            var mainPanel = document.getElementById("prohibitKeywords");
            for(var i=0; i<res.data.length; i++){
                var childDiv = document.createElement("span");
                childDiv.style.background = "#3ca793";
                childDiv.style.padding = "5px";
                childDiv.style.marginBottom = "3px";
                childDiv.style.marginTop = "2px";
                childDiv.style.marginRight = "5px";
                childDiv.style.color = "#fff";
                childDiv.style.display = "inline-block";
                childDiv.style.cursor = "pointer";
                childDiv.id = 'p'+i;
                childDiv.innerHTML = '<span>'+res.data[i]+'</span>';
                mainPanel.appendChild(childDiv);
                childDiv.onclick = function (  ) {

                    if(map.get(this.id) != null){
                        layer.msg("请勿重复添加!");
                        return;
                    }else {
                        //单个span标签的值
                        var spanValue = document.getElementById(this.id).innerText+",";
                        prohibitValues=prohibitValues+spanValue;
                        document.getElementById('shieldKeywords').value=prohibitValues.substring(0, prohibitValues.length - 1);
                        map.set(this.id,spanValue);
                    }

                }
            }
        }else {
            layer.msg(res.msg);
        }
    });



    var siftKeywords = document.getElementById('sift').value;
    if(siftKeywords != null){
        document.getElementById('siftKeywords').value = siftKeywords;
    }
    var shieldKeywords = document.getElementById('shield').value;
    if(shieldKeywords != null){
        document.getElementById('shieldKeywords').value = shieldKeywords;
    }


</script>
</body>
</html>